package com.itheima.xiancheng.demo1;

public class Foodie extends Thread{
    @Override
    public void run() {
        while(true){
            synchronized (Desk.obj){
                if (Desk.count==0){
                    break;
                }else {
                    if (Desk.flag){
                        System.out.println("吃货吃东西"+Desk.count);
                       Desk.count--;
                       Desk.flag=false;
                       Desk.obj.notify();
                    }else{
                        try {
                            Desk.obj.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                    }
                }
            }
        }
    }
}
